{extend name="public:adminbase" /}

{block name="content"}


<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-header">
          <h4>反馈列表</h4>
        </div>
        <div class="card-toolbar clearfix">

          <div class="toolbar-btn-action">
            <a target="_blank" class="btn btn-primary m-r-5" href="{:url('Article/create')}"><i class="mdi mdi-plus"></i> 新增</a>


            <!--<a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>-->
            <!--<a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>-->
            <!--<a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>-->
            <button class="btn btn-danger" id="dosubmit"><i class="mdi mdi-cloud"></i>推送到百度站长seo</button>
            <button class="btn " id="sitemap"><i class="mdi mdi-sitemap"></i>更新sitemap</button>
            <button class="btn btn-success m-r-5" onclick="location.reload()" ><i class="mdi mdi-refresh"></i> 刷新本页</button>
          </div>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>编号</th>
                  <th>标题</th>
                  <th>点击</th>
                  <th>排序</th>
                  <th>启用</th>
                  <th>置顶</th>
                  <th>推荐</th>
                  <th>热度</th>
                  <th>创建</th>
                  <th>修改</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                {foreach $list as $v}
                <tr>
                  <td>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" name="ids[]" value="{$v.id}"><span></span>
                    </label>
                  </td>
                  <td>{$v.id}</td>
                  <td>{$v.title}</td>
                  <td>{$v.rel_hits}</td>
                  <td>{$v.ordid}</td>
                  <td>
                    {switch $v.status}
                    {case 1 }<button data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-primary btn-xs">已启用</button>{/case}
                    {case 2 }<button data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-warning btn-xs">已禁用</button>{/case}
                    {default /}<button data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-primary btn-xs">已启用</button>
                    {/switch}
                  </td>
                  <td>
                    {switch $v.top}
                    {case 1 }<button onclick="change_top({$v.id})" data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-primary btn-xs">是</button>{/case}
                    {default /}<button onclick="change_top({$v.id})" data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-secondary btn-xs">否</button>
                    {/switch}
                  </td>
                  <td>
                    {switch $v.recommend}
                    {case 1 }<button onclick="change_recommend({$v.id})" data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-primary btn-xs">是</button>{/case}
                    {default /}<button onclick="change_recommend({$v.id})" data-toggle="tooltip" title="点击可直接更换状态" class="btn btn-label btn-secondary btn-xs">否</button>
                    {/switch}
                  </td>
                  <td>{$v.hits}</td>
                  <td>{$v.add_time}</td>
                  <td>{$v.last_time}</td>
                  <td>
                    <div class="btn-group">
                      <a target="_blank"  class="btn btn-xs btn-default" href="{:url('Uarticle/edit',['id'=>$v.id])}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                      <!--<button onclick="del({$v.id})" class="btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></button>-->
                    </div>
                  </td>
                </tr>
                {/foreach}

              </tbody>
            </table>
          </div>
          {$list|raw}
 
        </div>
      </div>
    </div>
    
  </div>
  
</div>
{include file="public/afooter"}
<script>
//  新增
  function AddCate(obj) {
    var url = $(obj).attr('href');
    layer.open({
      title:"新增分类",
      type: 2,
      area: ['500px', '450px'],
      fixed: false, //不固定
      maxmin: true,
      content: url
    });
  }

  //更新sitemap
$('#sitemap').click(function(){
  var url="{:url('AdminArticle/sitemap')}";
  $.post(url,{ids:1},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),3000);
    } else {
      error(e.msg);
    }
  })
})

  //推送到百度站长平台
$('#dosubmit').click(function(){
  var checkID = [];//定义一个空数组
  $("input[name='ids[]']:checked").each(function(i){
    //把所有被选中的复选框的值存入数组
    checkID[i] =$(this).val();
  });
//  console.log(checkID);
  var url="{:url('AdminArticle/push_to_baidu_all')}";
  $.post(url,{ids:checkID},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),3000);
    } else {
      error(e.msg);
    }
  })
})
//修改
//  function edit(obj) {
//    var url = $(obj).attr('href');
//    layer.open({
//      title:"修改",
//      type: 2,
//      area: ['500px', '450px'],
//      fixed: false, //不固定
//      maxmin: true,
//      content: url
//    });
//  }
//  删除
  function del(id) {
    layer.confirm('您确定要删除吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
      var url = "{:url('AdminCate/delete')}"
      $.post(url,{id:id},function (e) {
        if(e.code != 200){
          error(e.msg);
        }else {
          success(e.msg);
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 1000);
          window.parent.location.reload();
        }
      })
    }, function(){
      layer.msg('已取消');
    });
  }

  //修改置顶状态
  function change_top(id) {
    var url ="{:url('change_top')}";
    $.post(url,{id:id},function (e) {
      if(e.code ==200){
        success(e.msg);
        setTimeout(location.reload(),1000);
      } else {
        error(e.msg);
      }
    })
  }
  //修改推荐状态

function change_recommend(id) {
  var url ="{:url('change_recommend')}";
  $.post(url,{id:id},function (e) {
    if(e.code ==200){
      success(e.msg);
      setTimeout(location.reload(),1000);
    } else {
      error(e.msg);
    }
  })
}
</script>

{/block}